cmake_minimum_required(VERSION 3.1.0)
project(slam)
set(CMAKE_CXX_STANDARD 14)
# set(CMAKE_C_COMPILER "/usr/bin/gcc")
# set(CMAKE_CXX_COMPILER "/usr/bin/g++")

# catkin默认设置为on，但是这会导致一些linking问题
set(BUILD_SHARED_LIBS OFF)

# 使用fake_ros，默认打开
option(USE_ROS_STUB "Use ROS stub." TRUE)

if(USE_ROS_STUB)
  add_subdirectory(ros_stub)
  # 使用fake catkin编译catkin包
  list(INSERT CMAKE_MODULE_PATH 0 "${PROJECT_SOURCE_DIR}/ros_stub/cmake/modules/")
  set(catkin_EXPORTED_TARGETS ros_stub)
  set(catkin_LIBRARIES ros_stub)
endif()

# cartographer文件解析器会自动去寻找lua文件的地址
# 为了方便开发我们可以用这个来自定义LUA的地址
set(CARTOGRAPHER_CONFIGURATION_FILES_DIRECTORY "${PROJECT_SOURCE_DIR}/cartographer/configuration_files"
  CACHE PATH ".lua config file directory")

# 编译rosbridgecpp
include_directories(rosbridgecpp)
add_subdirectory(rosbridgecpp)
target_link_libraries(rosbridgecpp)

# 编译cartographer
add_subdirectory(cartographer)

# 定义Findcartographer.cmake，防止编译器迷路
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${PROJECT_SOURCE_DIR}/cmake/modules/")

# 添加编译原始ros的catkin包
add_subdirectory(cartographer_ros/cartographer_ros_msgs)
add_subdirectory(cartographer_ros/cartographer_ros)
# 把你的驱动程序放到这里
add_subdirectory(halloworld)
add_subdirectory(test_node_mem)
add_subdirectory(bind_test)
# add_subdirectory(rplidar_ros)
# add_subdirectory(path_to_your_sensor_driver)

add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)

if(NOT USE_ROS_STUB)
  #如果运行在装有真实ROS的机器上可以打开这个编译开关
  set(BUILD_SHARED_LIBS ON)
  add_subdirectory(cartographer_ros/cartographer_rviz)
endif()
